import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 牛客网: 首页 > 试题广场 > 最长上升子序列
 * <a href="https://www.nowcoder.com/questionTerminal/d83721575bd4418eae76c916483493de">...</a>
 * User: DELL
 * Date: 2023-05-11
 * Time: 23:13
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextInt();
            }
            System.out.println(getLISLength(arr));
        }
    }

    /**
     * 状态定义: dp[i] = 数组前 i 个元素的最长上升子序列的长度
     * 状态转移: 对于任意 j < i,
     *         若 arr[j] < arr[i] 则dp[i] = max(dp[j]+1,dp[i])
     * 初始值: 全部初始化为1
     * 返回值: 返回dp数组中的最大值即可
     */
    private static int getLISLength(int[] arr) {
        //状态数组
        int[] dp = new int[arr.length];
        //初始化
        Arrays.fill(dp,1);
        //状态转移
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < i; j++) {
                if (arr[j] < arr[i]) {
                    dp[i] = Math.max(dp[j]+1,dp[i]);
                }
            }
        }
        //遍历找出最大长度输出
        int maxLen = 0;
        for (int i = 0; i < arr.length; i++) {
            if (dp[i] > maxLen) {
                maxLen = dp[i];
            }
        }
        return maxLen;
    }
}
